﻿
namespace NoNameGoServer.Client.Commands {
    public class HandicapCommand : Command {
		private readonly int _handicap;

		public HandicapCommand(int handicap) {
			_handicap = handicap;
		}

		public override void Execute(NNGSClient nngsClient) {
            string cmd = string.Format("handicap {0}\n", _handicap);
            nngsClient.SendAsync(this, cmd, null);
        }

		public override void ProcessReceivedLine(NNGSClient nngsClient, string line, out bool processed) {
			if (line.StartsWith("5 handicap: Unknown command.")) {
				processed = true;
				throw new NNGSClientException("Received 'Unknown command' after handicap command.  Probably because the match command failed.");
			}
			
			base.ProcessReceivedLine(nngsClient, line, out processed);
		}
    }
}
